<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_Placard.asp
'= 摘    要：后台-站点公告文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"03") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "add"
	Call Add
Case "save"
	Call Save
Case "del"
	Call Del
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(1),FieldValue(1),TopicList
	Dim ListBlock,Temp
	
	Page=EA_Pub.SafeRequest(3,"page",0,1,0)
	
	PageContent=Template.LoadTemplate("admin_placard_list.htm")

	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Placard_Help",str_Placard_Help,PageContent

	Template.SetVariable "Language_Placard_PlacardList",str_Placard_PlacardList,PageContent
	Template.SetVariable "Language_Placard_AddPlacard",str_Placard_AddPlacard,PageContent
	Template.SetVariable "Language_Placard_Title",str_Placard_Title,PageContent
	Template.SetVariable "Language_Placard_AddTime",str_Placard_AddTime,PageContent
	Template.SetVariable "Language_Placard_OverTime",str_Placard_OverTime,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	Count=EA_M_DBO.Get_Placard_Total()(0,0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		TopicList=EA_M_DBO.Get_Placard_List(Page,15)
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "PlacardID",TopicList(0,i),Temp
			Template.SetVariable "PlacardTitle",TopicList(1,i),Temp
			Template.SetVariable "PlacardAddTime",TopicList(2,i),Temp
			Template.SetVariable "PlacardOverTime",TopicList(3,i),Temp
			
			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId
	Dim Title,Content,OverTime
	Dim Temp
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	Temp=EA_DBO.Get_PlacardInfo(PostId)
	If IsArray(Temp) Then 
		Title=Temp(0,0)
		Content=Temp(1,0)
		OverTime=FormatDateTime(Temp(2,0),2)
	End If

	PageContent=Template.LoadTemplate("admin_placard_option.htm")

	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent
	Template.SetVariable "Language_Comm_Reduce_Input",str_Comm_Reduce_Input,PageContent
	Template.SetVariable "Language_Comm_Zoom_Input",str_Comm_Zoom_Input,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Placard_Help",str_Placard_Help,PageContent

	Template.SetVariable "Language_Placard_PlacardList",str_Placard_PlacardList,PageContent
	Template.SetVariable "Language_Placard_AddPlacard",str_Placard_AddPlacard,PageContent
	Template.SetVariable "Language_Placard_Input_Placard",str_Placard_Input_Placard,PageContent
	Template.SetVariable "Language_Placard_Title",str_Placard_Title,PageContent
	Template.SetVariable "Language_Placard_Content",str_Placard_Content,PageContent
	Template.SetVariable "Language_Placard_OverTime",str_Placard_OverTime,PageContent

	Template.SetVariable "PlacardID",PostId,PageContent
	Template.SetVariable "Title",Title,PageContent
	Template.SetVariable "Content",Content,PageContent
	Template.SetVariable "OverTime",OverTime,PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim Title,Content,OverTime
	Dim PostId
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	Title=EA_Pub.SafeRequest(2,"title",1,"",1)
	Content=EA_Pub.SafeRequest(2,"info",1,"",0)
	OverTime=EA_Pub.SafeRequest(2,"date",2,Now()+7,0)
	
	If Title="" Or Len(Title)>150 Then
		ErrMsg="对不起，公告的标题长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于150"
		Call EA_Manager.Error(1)
	End If
	If Content="" Or Len(Content)>250 Then
		ErrMsg="对不起，公告的内容长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于250"
		Call EA_Manager.Error(1)
	End If
		
	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_Placard] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_Placard",Conn,2,2
		rs.AddNew
	End If
		rs("Title")=Title
		rs("Content")=Content
		rs("OverTime")=OverTime
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_placard.asp"
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	SQL="delete from [NB_Placard] where ID="&PostId
	Conn.Execute(SQL)
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
%>